
#ifndef __PROMPT_H
#define __PROMPT_H

#include <stdarg.h>

/** A class encapsulating a single user prompt. This will do nothing
 * and return only the given answer it is initialised with unless this
 * answer is NULL. Then the prompt will become command-line driven. */
class Prompt
{
   public:
      Prompt(const char *answer, int maxreplylength = 80);
      Prompt(const Prompt &o);
      Prompt &operator=(const Prompt &o);
      ~Prompt();
      int promptYesNoQuestion(const char *question, ...);
      const char *promptForPassword(const char *question, ...);
      char *promptNormal(const char *prompt);
      char *promptPassword(const char *prompt);
   private:
      void copy(const Prompt &o);
      int promptYesNoQuestion(const char *question, va_list args);
      const char *promptForPassword(const char *question, va_list args);
      /** A copy of the answer given, to be returned or re-processed on
       * any subsequent calls (so the user is not asked the same question
       * multiple times. */ 
      char *anscopy;
      /** A variable to keep the maximum allowable answer length. */
      int ansmaxlength;
};

#endif
